package com.yanqu.road.server.cmd.activity.platform;

import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.activity.PlatformActivityProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.manger.activity.platform.PlatformActivityMgr;
import com.yanqu.road.server.protocol.Protocol;

@Cmd(code = Protocol.S_PLATFORM_ACTIVITY_GET_REWARD,desc = "平台活动领取奖励")
public class UserPlatformGetRewardCmd extends AbstractCommand {

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {

        PlatformActivityProto.UserPlatformGetRewardReqMsg reqMsg = PlatformActivityProto.UserPlatformGetRewardReqMsg.parseFrom(packet.getBytes());

        ret = PlatformActivityMgr.getReward(player, reqMsg.getType());

    }

    @Override
    public void sendData(GamePlayer player) {
        if(ret != 0){
            player.sendPacket(Protocol.U_PLATFORM_ACTIVITY_GET_REWARD, PlatformActivityProto.UserPlatformGetRewardRespMsg.newBuilder().setRet(ret));
        }
    }
}
